;; 关闭滚动到底部的提示音
(setq ring-bell-function 'ignore)

;; default encoding
(set-language-environment "UTF-8")

;; 有修改自动加载
(global-auto-revert-mode t)

;; 缩写
(abbrev-mode t)
(define-abbrev-table 'global-abbrev-table '(
					    ;; sinagture
					    ("wys" "Wang YaSong")))

;; 关闭自动备份
(setq make-backup-files nil)

;; 自动保存关闭
(setq auto-save-default nil)

;; 最近打开文档
(recentf-mode 1)
(setq recentf-max-menu-item 10)

;; yes-or-no 换成 y-or-n
(fset 'yes-or-no-p 'y-or-n-p)

;; 启用括号匹配
(add-hook 'emacs-lisp-mode-hook 'show-paren-mode)
;; 当光标在括号里面的时候, 也能显示匹配的括号
(define-advice show-paren-function (:around (fn) fix-show-paren-function)
  "Highlight enclosing parens."
  (cond ((looking-at-p "\\s(") (funcall fn))
	(t (save-excursion
	     (ignore-errors (backward-up-list))
	     (funcall fn)))))

;; 选中字符后, 输入内容会替换掉, 而不是直接插入
(delete-selection-mode 1)

;; Dired 删除或复制文件夹的时候, 自动确认递归删除或复制
(setq dired-recursive-deletes 'always)
(setq dired-recursive-copies 'always)

;; Dired 每打开一次, 就生成一个buffer, 用下面的命令只生成一个
(put 'dired-find-alternate-file 'disabled nil)

;; dired
(require 'dired-x)
(setq dired-dwim-target t)

;; Emacs Lisp 不会补全'(单引号)
;; (sp-local-pair '(emacs-lisp-mode lisp-interaction-mode) "'" nil :actions nil)
;; (sp-local-pair '(emacs-lisp-mode lisp-interaction-mode) "`" nil :actions nil)

;; rg
(require 'rg)
(rg-enable-default-bindings)

(provide 'init-better-defaults)
